
******************
**** Table B9 ****
****************** 

use "$data/paymentdata_ready" , clear

bysort customer: egen interventionmeanpayment=mean(payment) if t>=1 & t<=3
winsor interventionmeanpayment, gen(interventionmeanpaymentw) p(0.01)

bysort customer: egen interventionmeaninvoice=mean(invoice) if t>=1 & t<=3
winsor interventionmeaninvoice, gen(interventionmeaninvoicew) p(0.01)

bysort customer: egen postmeanpayment=mean(payment) if t>=4 & t!=.
winsor postmeanpayment, gen(postmeanpaymentw) p(0.01)

bysort customer: egen postmeaninvoice=mean(invoice) if t>=4 & t!=.
winsor postmeaninvoice, gen(postmeaninvoicew) p(0.01)

log using "$output/table b9", replace


** panel A **
estpost tabstat interventionmeanpaymentw interventionmeaninvoicew , by(treatmentidentity) statistics(mean sd) columns(statistics) nototal  

** panel B **
estpost tabstat   postmeanpaymentw postmeaninvoicew , by(treatmentidentity) statistics(mean sd) columns(statistics) nototal  

log close

* To get the collection efficiency including remaining debt 
di 7.751787/(8.10118+(8.184576-6.682736)/3)
